package cn.com.anypay.manager.payment.dto;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;

/**
 * 查询结果数据传输对象
 *
 * 包含查询操作的返回结果
 *
 * @author AnyPay Team
 * @version 1.0
 * @since 2025-07-05
 */
public class QueryResultDTO {

    /**
     * 查询是否成功
     */
    private boolean success;

    /**
     * 错误代码
     */
    private String errorCode;

    /**
     * 错误信息
     */
    private String errorMessage;

    /**
     * 商户订单号
     */
    private String merchantOrderId;

    /**
     * 渠道订单号
     */
    private String channelOrderId;

    /**
     * 支付状态
     */
    private PaymentStatusDTO status;

    /**
     * 支付金额
     */
    private BigDecimal amount;

    /**
     * 实际支付金额
     */
    private BigDecimal paidAmount;

    /**
     * 货币类型
     */
    private String currency;

    /**
     * 支付时间
     */
    private Date payTime;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 完成时间
     */
    private Date finishTime;

    /**
     * 买家信息
     */
    private String buyerInfo;

    /**
     * 渠道响应的原始数据
     */
    private String rawData;

    /**
     * 扩展数据
     */
    private Map<String, Object> extData;

    public QueryResultDTO() {
    }

    public QueryResultDTO(boolean success) {
        this.success = success;
    }

    public QueryResultDTO(boolean success, String errorCode, String errorMessage) {
        this.success = success;
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    /**
     * 创建成功结果
     */
    public static QueryResultDTO success() {
        return new QueryResultDTO(true);
    }

    /**
     * 创建失败结果
     */
    public static QueryResultDTO failure(String errorCode, String errorMessage) {
        return new QueryResultDTO(false, errorCode, errorMessage);
    }

    // Getters and Setters
    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public String getMerchantOrderId() {
        return merchantOrderId;
    }

    public void setMerchantOrderId(String merchantOrderId) {
        this.merchantOrderId = merchantOrderId;
    }

    public String getChannelOrderId() {
        return channelOrderId;
    }

    public void setChannelOrderId(String channelOrderId) {
        this.channelOrderId = channelOrderId;
    }

    public PaymentStatusDTO getStatus() {
        return status;
    }

    public void setStatus(PaymentStatusDTO status) {
        this.status = status;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public BigDecimal getPaidAmount() {
        return paidAmount;
    }

    public void setPaidAmount(BigDecimal paidAmount) {
        this.paidAmount = paidAmount;
    }

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        this.currency = currency;
    }

    public Date getPayTime() {
        return payTime;
    }

    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getFinishTime() {
        return finishTime;
    }

    public void setFinishTime(Date finishTime) {
        this.finishTime = finishTime;
    }

    public String getBuyerInfo() {
        return buyerInfo;
    }

    public void setBuyerInfo(String buyerInfo) {
        this.buyerInfo = buyerInfo;
    }

    public String getRawData() {
        return rawData;
    }

    public void setRawData(String rawData) {
        this.rawData = rawData;
    }

    public Map<String, Object> getExtData() {
        return extData;
    }

    public void setExtData(Map<String, Object> extData) {
        this.extData = extData;
    }

    @Override
    public String toString() {
        return "QueryResult{" +
                "success=" + success +
                ", errorCode='" + errorCode + '\'' +
                ", errorMessage='" + errorMessage + '\'' +
                ", merchantOrderId='" + merchantOrderId + '\'' +
                ", channelOrderId='" + channelOrderId + '\'' +
                ", status=" + status +
                ", amount=" + amount +
                ", paidAmount=" + paidAmount +
                ", currency='" + currency + '\'' +
                ", payTime=" + payTime +
                ", createTime=" + createTime +
                ", finishTime=" + finishTime +
                ", buyerInfo='" + buyerInfo + '\'' +
                ", rawData='" + rawData + '\'' +
                ", extData=" + extData +
                '}';
    }
}